package com.kupurui.asteacher.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.android.frame.adapter.CommonAdapter;
import com.android.frame.adapter.ViewHolder;
import com.kupurui.asteacher.R;
import com.kupurui.asteacher.bean.PreviewInfo;

import java.util.List;

/**
 * Created by Administrator on 2017/8/22.
 */

public class PreviewCompletionAdapter extends CommonAdapter<PreviewInfo> {
    public PreviewCompletionAdapter(Context context, List<PreviewInfo> mList, int itemLayoutId) {
        super(context, mList, itemLayoutId);
    }

    @Override
    public void convert(ViewHolder holder, final PreviewInfo item, int positon) {
        final ImageView ivSelector = holder.getView(R.id.iv_selector);
        if (item.getIs_selector()){
            ivSelector.setSelected(true);
        }else{
            ivSelector.setSelected(false);
        }
        ivSelector.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (item.getIs_selector()){
                    item.setIs_selector(false);
                }else{
                    item.setIs_selector(true);
                }
                notifyDataSetChanged();
            }
        });
    }
}
